
var ctx = ctx;



function loadListData(applyNum,visitNo,patientName,sex,age,appDept,patBloodGroup,rh,chargeType,createDate,appDoctorName,fastSlow){
    $("#visitNo").html(visitNo);
    $("#patientName").html(patientName);
    $("#sex").html(sex);
    $("#age").html(age);
    $("#appDept").html(appDept);
    $("#patBloodGroup").html(patBloodGroup);
    $("#rh").html(rh);
    $("#chargeType").html(chargeType);
    $("#createDate").html(createDate);
    $("#appDoctorName").html(appDoctorName);
    $("#fastSlow").html(fastSlow);
    loadDiv('applyDataTbody',ctx+'/blood/bloodOutSheet/applyListData?applyNum='+applyNum);
    loadDiv('matchDataTbody',ctx+'/blood/bloodOutSheet/matchListData?applyNum='+applyNum);
}
var rowIndex = 0;
function waitOutSheetFun(applyId,matchId,bloodId,componentId,bloodCapacity,applyNum,obj){
   var flag =  $(obj).children().find("input").val();
   if(flag=='0'){
       $.ajax({
           type: "POST",
           url: ctx+'/blood/bloodOutSheet/waitOutSheetData?applyId='+applyId+'&matchSheetId='+matchId+'&bloodId='+bloodId+'&componentId='+componentId+'&bloodCapacity='+bloodCapacity,
           dataType: "json",
           success: function (data) {
               if (data!=null) {
                   /*应先获取所有数据，判断与所选数据是否重复，重复则不再追加*/

                   var trHTML = "<tr>";
                   trHTML += "<td >"+data.blood_id +"</td>";
                   trHTML += "<td>"+data.blood_name  +"</td>";
                   trHTML += "<td>"+data.pat_blood_group  +"</td>";
                   trHTML += "<td>"+data.rh  +"</td>";
                   trHTML += "<td>"+data.blood_capacity  +"</td>";
                   trHTML += "<td>"+data.unit  +"</td>";
                   trHTML += "<td>"+data.inval_date  +"</td>";
                   trHTML += "<td>"+data.blood_donor_name  +"</td>";
                   trHTML += "<td>"+data.costs  +"</td>";
                   trHTML += "<td>"+data.charges  +"" +
                       "<input name='sheetList["+rowIndex+"].applyId' type='hidden' value='"+applyId+"'/>" +
                       "<input name='sheetList["+rowIndex+"].bloodId' type='hidden' value='"+data.blood_id+"'/>" +
                       "<input name='sheetList["+rowIndex+"].matchSheetId' type='hidden' value='"+data.match_id+"'/>" +
                       "<input name='sheetList["+rowIndex+"].componentId' type='hidden' value='"+data.component_id+"'/>" +
                       "<input name='sheetList["+rowIndex+"].applyNum' type='hidden' value='"+applyNum+"'/>" +
                       "<input name='sheetList["+rowIndex+"].flag' type='hidden' value='0'/></td>";
                   trHTML += "</tr>";
                   rowIndex++;
                   $('#outSheetDataTbody').append(trHTML);
               } else {
                   toastr.info('没有相应的血液成分与价表对照');
               }
           },
           error: function(data) {
               toastr.error('网络连接错误,请检查网络');
           }
       });
       $(obj).children().find("input").val("1");
   }else{
       toastr.error('该已配血液已添加，不能重复添加！');
   }

}
